package equipeAgentes2012;

import robocode.BulletHitBulletEvent;
import robocode.BulletHitEvent;
import robocode.BulletMissedEvent;
import robocode.Droid;
import robocode.HitByBulletEvent;
import robocode.TeamRobot;

public class KillAllSlave2348434 extends TeamRobot implements Droid {

	public boolean hit;
	public void run() {
		while(true){
			if(!hit){
				setFire(0.1);
				setTurnGunRight(5);
				execute();
			}else {
				setFire(3);
				execute();
			}
		}
	}
	
	public void onBulletHit(BulletHitEvent e){
		if(this.getGunHeading() >  e.getBullet().getHeading()){
			turnGunLeft( this.getGunHeading() -  e.getBullet().getHeading());
		}else {
			turnGunRight(e.getBullet().getHeading() - this.getGunHeading() );
		}
		hit = true;
	}
	public void onHitByBullet(HitByBulletEvent e){
		if (!hit){
		if(this.getGunHeading() >  (e.getBullet().getHeading() -180)){
			turnGunLeft( this.getGunHeading() -  (e.getBullet().getHeading() -180));
		}else {
			turnGunRight((e.getBullet().getHeading() -180) - this.getGunHeading() );
		}
		hit = true;
		}
	}
	public void onBulletMissed(BulletMissedEvent e){
		if(e.getBullet().getPower() > 0.1){
			hit = false;
		}
	}
}
